import * as CryptoJS from 'crypto-js';


const other = {
	encryption: (src, keyWord) => {
		return encryption(src, keyWord);
	},
	decryption: (src, keyWord) => {
		return decryption(src, keyWord);
	}
};



/**
 *加密处理
 */
export function encryption(src, keyWord) {
	const key = CryptoJS.enc.Utf8.parse(keyWord);
	// 加密
	var encrypted = CryptoJS.AES.encrypt(src, key, {
		iv: key,
		mode: CryptoJS.mode.CFB,
		padding: CryptoJS.pad.NoPadding,
	});
	return encrypted.toString();
}

/**
 *  解密
 * @param {*} params 参数列表
 * @returns 明文
 */
export function decryption(src, keyWord) {
	const key = CryptoJS.enc.Utf8.parse(keyWord);
	// 解密逻辑
	var decryptd = CryptoJS.AES.decrypt(src, key, {
		iv: key,
		mode: CryptoJS.mode.CFB,
		padding: CryptoJS.pad.NoPadding,
	});

	return decryptd.toString(CryptoJS.enc.Utf8);
}

// 侧式1
const a=encryption("123456")
console.log("测试aes加解密输出",a)
console.log(decryption(a))



// 统一批量导出
export default other;